<!DOCTYPE html>
<html>
    
    <head>
        <title>打开APP应用</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no" />
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
        <script src="jquery-3.2.0.min.js" type="text/javascript"></script>
        <style>
            * {margin:0;padding:0;}
            .container {
                width:100%;
                height:100%;
                position:absolute;
            }
            .button_div {
                position:absolute;
                left:50%;
                top:50%;
                background:#DDDDDD;
                width:40%;
                text-align:center;
                transform:translate(-50%, -50%);
                border-radius:0.5em;
            }
            .button_a {
                display:inline-block;
                margin-top:1em;
            }
        </style>
        <script>
            function openHtml() {
                window.location.href = "http://m.9you.com/";
            }
            function timeoutRedirect(url) {
                var startTime = Date.now();
                var timeout = 500;
                openApp(url);
                var t = setTimeout(function(){
                    var endTime = Date.now();
                    if (endTime - startTime < timeout + 100) {
                        openHtml();
                    }
                }, timeout);
                window.onblur = function() {
                    clearTimeout(t);
                }
            }

            function openApp(url) {
                openAppByIframe(url);
            }

            function openAppByLocation(url) {
                try {
                    window.location.href = url;
                } catch(e) {
                    alert(e);
                }
            }

            function openAppByIframe(url) {
                var iframe = document.createElement("iframe");
                iframe.style.display = "none";
                iframe.src = url;
                document.body.appendChild(iframe);
                setTimeout(function() {
                    document.body.removeChild(iframe);
                }, 500);
            }
            function openAppHomePage() {
                var url = "demoadvert://homepage";
                timeoutRedirect(url);
            }
            function openAppInternalPage() {
                var url = "demoadvert://interstitial";
                timeoutRedirect(url);
            }
            function downloadApp() {
                var url = "extra/AdvertDemo.apk";
                window.location.href = url;
            }
        </script>
    </head>
    <body>
        <div class="container">
            <div class="button_div">
                <a class="button_a" href="javascript:void(0);" onclick="openAppHomePage();">打开首页</a><br/>
                <a class="button_a" href="javascript:void(0);" onclick="openAppInternalPage();">打开内部页面</a><br/>
                <a class="button_a" href="javascript:void(0);" onclick="downloadApp();">下载App</a><br/><br/>
            </div>
        </div>
    </body>

</html>
